<?php

require_once APPLICATION_PATH.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'Component_Abstract.php';

class NewsTicker extends Component_Abstract  {
	
	private $_content;
        private $_firstContent;


        public function setFirstContent($data) {
            $this->_firstContent=$data;
            return $this;
        }

        public function getFirstContent() {
            return $this->_firstContent;
        }

        public function setContent($content) {
		$this->_content=$content;
                return $this;
	}
	
	public function getContent() {
		return $this->_content;
	}
	
	public function initComponent() {
                if (!is_null($this->getParameter('selected_doc_gid'))) {
                    
                        $tb = new Default_Model_Documents();
                        $rows=$tb->findByGroupId($this->getParameter('selected_doc_gid'));
                        foreach ($rows as &$row) {
                            $row=$row->content;
                        }

                        $firstrow=array_shift($rows);

                        if (is_array($firstrow))
                            $firstrow=$firstrow->content;

                        
                        $this->setFirstContent($firstrow)
                             ->setContent($rows);

                }

	}
	
	public function show() {
	    $ret=$this->getTmplContent($this->getConfig()->phtml->newsticker);
            return $ret;
	}

        public function demo() {
            $ret=$this->getTmplContent($this->getConfig()->phtml->demopage);
            return $ret;
        }


        public function getConfigPage() {

            return false;

        }

        public function getOptionsDiv() {
            
            $ret=$this->getTmplContent($this->getConfig()->phtml->optionspage);
            return $ret;

        }


}
